[root@server1 ~]# postconf 2bounce_notice_recipient = postmaster access_map_defer_code = 450 access_map_reject_code = 554 address_verify_cache_cleanup_interval = 12h address_verify_default_transport = $default_transport ...
Email Architecture and Null Clients
Email Message Transmission
Postfix
Postfix Null Client Configuration
Linux servers send email to report errors and to administrators
Generally use /usr/sbin/sendmail
Most servers send mails when incidents occur
Uses corporate SMTP server to transmit messages
Null client: Client machine that runs local mail server that forwards emails to outbound mail relay for delivery
Does not accept local delivery for any messages
Can only send messages to outbound mail relay
Users may run mail clients on null client to read and send emails
To send email, mail client communicates with outgoing mail server
Server helps relay message to final destination
Client uses SMTP to transmit messages to server
If outgoing mail relay requires no authentication from internal clients, server listens on port 25/TCP
Relay restrict hosts that can relay
IP address-based restrictions or firewall rules
If outbound SMTP relay is reachable from Internet, normally configured as MSA
MSA listens on port 587/TCP and requires authentication of client before accepting mail
May be username/password or other means
Outgoing mail relay uses DNS to look up MX record
Identifies mail server that accepts delivery for messages sent to recipient domain
Relay uses SMTP on port 25/TCP to transmit email to server
|
Postfix: Powerful, easy-to-configure mail server
Default mail server in Red Hat Enterprise Linux 7
Provided by postfix RPM package
Modular program made up of several programs
Components controlled by master process
/etc/postfix/main.cf: Main configuration file of postfix mail server
/etc/postfix contains other configuration files
/etc/postfix/master.cf controls subservices that are started
Setting | Purpose | Default |
|
|
|
|
|
|
|
| `relayhost = ` |
|
|
|
|
|
|
|
|
|
Two ways to edit /etc/postfix/main.cf:
By hand using a text editor such as vim
Using postconf utility
postconf lets you:
Query by individual/all settings
Modify settings
Query defaults
Showing all settings that differ from built-in defaults
To query all settings from /etc/postfix/main.cf, run postconf without any parameter:
[root@server1 ~]# postconf 2bounce_notice_recipient = postmaster access_map_defer_code = 450 access_map_reject_code = 554 address_verify_cache_cleanup_interval = 12h address_verify_default_transport = $default_transport ...
To query particular set of options, list them after postconf
Example: To list inet_interfaces and myorigin options with corresponding values:
[root@server1 ~]# postconf inet_interfaces myorigin inet_interfaces = loopback-only myorigin = $myhostname
If value in /etc/postfix/main.cf starts with $, it is not a literal value
Instead points to value of different setting
Syntax simplifies maintenance; need to update value in one place only
To add or change options in /etc/postfix/main.cf:
postconf -e 'setting = value'
If setting with name already exists in configuration file, it is updated to new value
Otherwise it is added to bottom of configuration file
To change myorigin to rewrite domain part of FROM: address to example.com:
[root@server1 ~]# postconf -e 'myorigin = example.com'
postfix requires reload or restart after making changes to /etc/postfix/main.cf. |
When troubleshooting email, log of all mail-related operations kept in systemd and /var/log/maillog
Includes information on mail server-related actions
To display list of queued outgoing mail messages, use postqueue -p
To attempt to deliver all queued messages again immediately, use postqueue -f command
Otherwise, Postfix attempts to resend once an hour until messages accepted or expire
|
postconf(5) man page
Adjust relayhost to point to corporate mail server:
Enclose host name of corporate mail server in square brackets
[root@server1 ~]# postconf -e "relayhost=[smtp1.example.com]"
Configure Postfix mail server to only relay emails from local system
Let mail server listen on loopback interface for emails to deliver only:
[root@server1 ~]# postconf -e "inet_interfaces=loopback-only"
Change null client configuration so it forwards mails originating from 127.0.0.0/8 IPv4 network and [::1]/128 IPv6 network to relay host:
[root@server1 ~]# postconf -e "mynetworks=127.0.0.0/8 [::1]/128"
Configure Postfix so outgoing mails have sender domain rewritten to company domain example.com:
[root@server1 ~]# postconf -e "myorigin=desktop1.example.com"
Prohibit Postfix mail server from delivering messages to local accounts
Configure the null client not to act as end point for any mail domain:
Does not accept mails where recipient is local email account for local delivery
Need to set mydestination to empty value
[root@server1 ~]# postconf -e "mydestination="
Configure local null client not to sort mails into mailboxes on local system:
Local email delivery turned off
[root@server1 ~]# postconf -e "local_transport=error: local delivery disabled"
Restart local postfix null client:
[root@server1 ~]# systemctl restart postfix
Directive | Null Client (server1.example.com) |
inet_interfaces | inet_interfaces = loopback-only |
myorigin | myorigin = desktop1.example.com |
relayhost | relayhost = [smtp1.example.com] |
mydestination | mydestination = |
local_transport | local_transport = error: local delivery disabled |
mynetworks | mynetworks = 127.0.0.0/8, [::1]/128 |
Man pages: postconf(1), postconf(5), mail(1), and mutt(1)
Email Architecture and Null Clients
Email Message Transmission
Postfix
Postfix Null Client Configuration
Nice job!
Click the button below to complete this module of the course:
Click the button below to continue to the course homepage:
Please continue with the next item in the course.